// Variables
$color-ink: #2C3333;
$color-paper: #F5F5F5;
$color-accent: #8B7355;
$font-noto: 'Noto Serif SC', serif;

// Mixins
@mixin flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

@mixin flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

// Common styles
.page-container {
  width: 100%;
  height: 100%;
  background-color: white;
  border-radius: 1.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.page-title {
  font-family: $font-noto;
  font-size: 1.5rem;
  color: $color-ink;
  font-weight: 500;
}

.page-subtitle {
  color: rgba($color-accent, 0.8);
  margin-top: 0.5rem;
  font-size: 0.875rem;
}

// Grade Selection Component
.grade-grid {
  display: grid;
  gap: 1rem;

  .grade-section {
    grid-column: span 2;

    .section-title {
      font-family: $font-noto;
      font-size: 0.875rem;
      color: rgba($color-ink, 0.6);
      margin-bottom: 0.75rem;
    }
  }

  .primary-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .middle-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
  }

  .grade-button {
    background-color: $color-paper;
    padding: 1rem;
    border-radius: 0.75rem;
    transition: background-color 0.2s;

    &:hover {
      background-color: rgba($color-accent, 0.05);
    }

    .grade-number {
      font-size: 1.5rem;
      color: $color-accent;
      margin-bottom: 0.25rem;
      display: block;
    }

    .grade-label {
      font-size: 0.75rem;
      color: rgba($color-ink, 0.6);
    }
  }
}

.history-section {
  margin-top: auto;

  .history-card {
    background-color: $color-paper;
    border-radius: 0.75rem;
    padding: 1rem;

    .history-header {
      @include flex-between;
      margin-bottom: 0.5rem;

      .poem-title {
        font-size: 0.875rem;
        font-family: $font-noto;
        color: $color-ink;
      }

      .grade-info {
        font-size: 0.75rem;
        color: rgba($color-accent, 0.6);
      }
    }

    .history-footer {
      @include flex-between;

      .author-name {
        font-size: 0.75rem;
        color: rgba($color-ink, 0.6);
      }

      .reprint-button {
        color: $color-accent;
        font-size: 0.875rem;
        &:hover {
          color: rgba($color-accent, 0.8);
        }
      }
    }
  }
}

// Poem Recommendations Component
.recommendations-header {
  @include flex-between;
  margin-bottom: 1.5rem;

  .header-left {
    display: flex;
    align-items: center;

    .back-button {
      padding: 0.5rem;
      border-radius: 0.5rem;
      transition: background-color 0.2s;

      &:hover {
        background-color: $color-paper;
      }
    }

    .icon {
      height: 1.25rem;
      width: 1.25rem;
      color: $color-ink;
    }
  }

  .difficulty-label {
    color: rgba($color-accent, 0.6);
    font-size: 0.875rem;
  }
}

.recommendations-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.featured-recommendation {
  background-color: rgba($color-accent, 0.05);
  padding: 1rem;
  border-radius: 0.75rem;
  border: 1px solid rgba($color-accent, 0.1);

  .recommendation-header {
    @include flex-between;
    margin-bottom: 0.75rem;

    .ai-tag {
      font-size: 0.75rem;
      color: rgba($color-accent, 0.6);
      background-color: rgba($color-accent, 0.1);
      padding: 0.25rem 0.5rem;
      border-radius: 9999px;
    }
  }
}

.regular-recommendation {
  background-color: $color-paper;
  padding: 1rem;
  border-radius: 0.75rem;
  transition: background-color 0.2s;

  &:hover {
    background-color: rgba($color-accent, 0.05);
  }
}

.difficulty-indicator {
  display: flex;
  align-items: center;
  gap: 0.25rem;

  .difficulty-text {
    font-size: 0.75rem;
    color: rgba($color-accent, 0.6);
  }

  .difficulty-dots {
    display: flex;
    gap: 0.125rem;

    .dot {
      width: 1rem;
      height: 0.25rem;
      border-radius: 9999px;
      background-color: rgba($color-accent, 0.2);

      &.active {
        background-color: $color-accent;
      }
    }
  }
}

.recommendation-footer {
  @include flex-between;
  margin-top: 0.5rem;

  .author-name {
    font-size: 0.75rem;
    color: rgba($color-accent, 0.6);
  }

  .print-button {
    color: $color-accent;
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: background-color 0.2s;

    &:hover {
      background-color: rgba($color-accent, 0.1);
    }
  }
}

// Print Preview Component
.preview-card {
  background-color: $color-paper;
  border-radius: 0.75rem;
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;

  .poem-header {
    text-align: center;
    margin-bottom: 1.5rem;

    .poem-title {
      font-family: $font-noto;
      font-size: 1.25rem;
      color: $color-ink;
      margin-bottom: 0.5rem;
    }
  }
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;

  .character-cell {
    aspect-ratio: 1;
    background-color: white;
    border-radius: 0.5rem;
    @include flex-center;
    color: rgba($color-ink, 0.2);
    font-size: 0.75rem;
  }
}

.print-settings {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;

  .setting-row {
    @include flex-between;

    .setting-label {
      font-size: 0.875rem;
      color: rgba($color-ink, 0.6);
    }

    .setting-options {
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }
  }
}

.size-button,
.option-button {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  @include flex-center;
  color: $color-accent;
  transition: all 0.2s;

  &:hover {
    background-color: rgba($color-accent, 0.1);
  }

  &.active {
    background-color: $color-accent;
    color: white;
  }
}

.print-button {
  margin-top: 1.5rem;
  width: 100%;
  background-color: $color-accent;
  color: white;
  padding: 0.75rem 0;
  border-radius: 0.75rem;
  font-family: $font-noto;
  @include flex-center;
  transition: background-color 0.2s;

  &:hover {
    background-color: rgba($color-accent, 0.9);
  }

  .icon {
    height: 1.25rem;
    width: 1.25rem;
    margin-right: 0.5rem;
  }
}

// Hide scrollbar but keep functionality
.scrollbar-hide {
  &::-webkit-scrollbar {
    display: none;
  }
  -ms-overflow-style: none;
  scrollbar-width: none;
}

// Dialog Component
.dialog-header {
  @include flex-between;
  margin-bottom: 1.5rem;

  .header-left {
    display: flex;
    align-items: center;
    gap: 1rem;

    .back-button {
      padding: 0.5rem;
      border-radius: 0.5rem;
      transition: background-color 0.2s;

      &:hover {
        background-color: $color-paper;
      }
    }

    .icon {
      height: 1.25rem;
      width: 1.25rem;
      color: $color-ink;
    }
  }
}

.dialog-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: calc(100% - 4rem);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background-color: $color-paper;
  border-radius: 0.75rem;
  margin-bottom: 1rem;

  &::-webkit-scrollbar {
    width: 0.5rem;
  }

  &::-webkit-scrollbar-track {
    background: transparent;
  }

  &::-webkit-scrollbar-thumb {
    background: rgba($color-accent, 0.2);
    border-radius: 9999px;
  }
}

.message {
  max-width: 80%;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;

  &.user-message {
    align-self: flex-end;
    
    .message-content {
      background-color: $color-accent;
      color: white;
      border-radius: 1rem 1rem 0 1rem;
    }

    .message-time {
      text-align: right;
    }
  }

  &.ai-message {
    align-self: flex-start;
    
    .message-content {
      background-color: white;
      color: $color-ink;
      border-radius: 1rem 1rem 1rem 0;
    }
  }

  .message-content {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  }

  .message-time {
    font-size: 0.75rem;
    color: rgba($color-ink, 0.4);
  }
}

.input-container {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  background-color: white;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);

  textarea {
    flex: 1;
    min-height: 2.5rem;
    max-height: 8rem;
    padding: 0.75rem;
    border: 1px solid rgba($color-accent, 0.2);
    border-radius: 0.5rem;
    resize: none;
    font-size: 0.875rem;
    line-height: 1.5;
    color: $color-ink;

    &:focus {
      outline: none;
      border-color: $color-accent;
    }

    &::placeholder {
      color: rgba($color-ink, 0.4);
    }
  }

  .send-button {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.5rem;
    background-color: $color-accent;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;

    &:hover:not(:disabled) {
      background-color: rgba($color-accent, 0.9);
    }

    &:disabled {
      background-color: rgba($color-accent, 0.3);
      cursor: not-allowed;
    }

    .icon {
      height: 1.25rem;
      width: 1.25rem;
    }
  }
} 